<!DOCTYPE html>
<html>
<head>
 {{template "header"}}
 <link rel="stylesheet" href="../static/editor/examples/css/style.css"/>
 <link rel="stylesheet" href="../static/editor/css/editormd.css"/>
</head>
<body>
<div >
	{{template "navbar" .}}
	<div style="padding:100px; ">
	{{with .Topic}}
	<div class="input-group">
 	 <input type="text" class="form-control" name="topic_heard" placeholder="文章标题"  value="{{.Title}}" aria-describedby="basic-addon2">

	  <span class="input-group-btn">
		<button type="button" class="btn btn-default" id="sizing-addon3" onclick="post()">提交文章</button>
	 </span>
	</div>
	<br/>
	<div id="layout">
		<div id="test-editormd">
			<textarea style="display: none;">
				{{str2html .Content_md}}
			</textarea>
		</div>
	</div>
	{{end}}
	<script src="../static/editor/examples/js/jquery.min.js"></script>
	<script src="../static/editor/editormd.min.js"></script>
	<script type="text/javascript">
		var testEditor;
		$(function() {
			testEditor = editormd("test-editormd" , {
				width : "100%",
				height : 640,
				theme : "dark",
				previewTheme : "dark",
				syncScrolling : "sinle",
				tex: true,// 开启科学公式TeX语言支持，默认关闭

				path : "../static/editor/lib/",
				saveHTMLToTextarea : true
			})
		})
		function post() {
			var text = document.getElementsByClassName("editormd-markdown-textarea");
			var html = document.getElementsByClassName("markdown-body");
			var topic_heard = document.getElementsByName("topic_heard");
			var form = document.createElement("form");
			
			form.action = "/update";
			form.method = "post";
			form.style.display = "none";
			
			var opt1 = document.createElement("input");
			opt1.name = "text";
			opt1.value = text[0].innerHTML;
			
			var opt2 = document.createElement("input");
			opt2.name = "html";
			opt2.value = html[0].innerHTML;
			
			var opt3 = document.createElement("input");
			opt3.name = "topic_heard";
			opt3.value = topic_heard[0].value;
			
			form.appendChild(opt1);
			form.appendChild(opt2);
			form.appendChild(opt3);
			
			document.body.appendChild(form);
			form.submit();

		}
	
	</script>
	</div>
</div>
	
</body>
</html>













